<?php
!function_exists('readover') && exit('Forbidden');

/****

@name:运气卡
@type:会员类
@effect:使用后随机加减积分。

****/

if($tooldb['type']!=2){
	Showmsg('tooluse_type_error');  // 判断道具类型是否设置错误
}
$num=$newcredit='';
$rt = $db->get_one("SELECT currency FROM pw_memberdata WHERE uid=".pwEscape($winduid));
$num=mt_rand(-300,300);
$newcurrency= $rt['currency']+$num;
$db->update("UPDATE pw_memberdata SET currency=".pwEscape($newcurrency)."WHERE uid=".pwEscape($winduid));
$db->update("UPDATE pw_usertool SET nums=nums-1 WHERE uid=".pwEscape($winduid)."AND toolid=".pwEscape($toolid));
$logdata=array(
	'type'		=>	'use',
	'descrip'	=>	'tool_15_descrip',
	'uid'		=>	$winduid,
	'username'	=>	$windid,
	'ip'		=>	$onlineip,
	'time'		=>	$timestamp,
	'toolname'	=>	$tooldb['name'],
	'newcurrency'=>$newcurrency,
);

writetoollog($logdata);
$msg='';
if($num>0){
	$msg='祝贺您获得'.$num.'个交易币';
}elseif($num<0){
	$msg='不幸，您的交易币被扣除'.$num.'个';
}
Showmsg($msg);
?>